<?php
class Model_Category_Place extends Model_Category  {
	
	public function getTable()
	{
		return new Model_DbTable_Category(); 
	}
	
	public function getItems(){
		if($this->_row->id){
			$select = $this->_table->getAdapter()->select()->from(array('p'=>'place'))
				->join(array('c'=>'connect_category_place'), "c.category_id = {$this->_row->id}",array())
			    ->where('c.item_id = p.id')->where('publicate = 1');
			$adapter = new Zend_Paginator_Adapter_DbSelect($select);
			return new Zend_Paginator($adapter);
		} else {
			$place = new Model_Place();
			return $place->getAll(true, true);
		}
	}
}